<template>
  <div class="bar">
    <div class="bar-echart" v-for="(item, index) in dataTotal" :key="index" @click="pillarClick(index)">
      <div class="bar-echart-top">
        <div class="bar-echart-top-item" :style="{ height: (northData[index] / item) * 4 + 'vh' }"></div>
      </div>
      <div class="bar-echart-center">{{ nameData[index].split(',')[0] }}<br />{{ nameData[index].split(',')[1] }}</div>
      <div class="bar-echart-bottom">
        <div class="bar-echart-bottom-item" :style="{ height: (southData[index] / item) * 4 + 'vh' }"></div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  /**
   * @description   跨江大桥echart
   * @author       刘晖(liuh@microvideo.cn)
   * @date         2021/10/8 19:38
   */
  name: 'RiverEchart',
  data() {
    return {}
  },
  props: {
    dataTotal: {
      default() {
        return []
      },
      type: Array
    },
    northData: {
      default() {
        return []
      },
      type: Array
    },
    southData: {
      default() {
        return []
      },
      type: Array
    },
    nameData: {
      default() {
        return []
      },
      type: Array
    }
  },
  filters: {},
  methods: {
    separateNum(str) {
      let counter = 0
      let result = ''
      for (let j = str.length - 1; j >= 0; j--) {
        counter++
        result = str.charAt(j) + result
        if (!(counter % 3) && j != 0) {
          result = ',' + result
        }
      }
      return result
    },
    /**
     * 柱子点击
     */
    pillarClick(item) {
      this.$emit('pillarClick', this.nameData[item], 'channel')
    }
  },
  mounted() {},
  created() {}
}
</script>

<style scoped>
.bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
}

.bar-echart {
  width: 40px;
  /* height: 12vh; */
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.bar-echart-top {
  width: 100%;
  height: 30%;
  display: flex;
  justify-content: center;
  border-radius: 2vh;
  position: relative;
}

.bar-echart-top-item {
  width: 6px;
  /* background: #0A6FFA; */
  background: linear-gradient(0deg, rgba(51, 133, 255, 0) 0%, #3385ff 100%);
  border-radius: 2vh;
  position: absolute;
  bottom: 0;
}

.bar-echart-top-count {
  width: 100%;
  text-align: center;
  /* color: #0A6FFA; */
  background: linear-gradient(0deg, rgba(51, 133, 255, 0) 0%, #3385ff 100%);
  border-radius: 2vh;
  position: absolute;
}

.bar-echart-center {
  width: 100%;
  max-height: 4vh;
  word-break: break-all;
  font-size: 1.2vh;
  text-align: center;
  line-height: 16px;
}

.bar-echart-bottom {
  width: 6px;
  height: 30%;
  /* background: #DBDDDB; */
  border-radius: 2vh;
  position: relative;
}

.bar-echart-bottom-item {
  width: 6px;
  background: linear-gradient(0deg, #2fc576 0%, rgba(47, 197, 118, 0.1) 100%);
  border-radius: 2vh;
  position: absolute;
  top: 0;
}

.bar-echart-bottom-count {
  width: 100%;
  text-align: center;
  color: #ff9600;
  border-radius: 2vh;
  position: absolute;
}
</style>
